package com.eii.eiimq.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: eii
 * @time: 2020/7/10 10:18 下午
 */
@Service
public class SmgTaskService {

    private static Logger logger = LoggerFactory.getLogger(SmgTaskService.class);

    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     * 发布消息
     *
     * @param msg
     * @param ex
     * @param routingKey
     */
    public void publish(String msg, String ex, String routingKey) {
        rabbitTemplate.convertAndSend(ex, routingKey, msg);
        //发布消息后，记录日志(执行消息发送完成后业务操作)
        logger.info("生产者 发送消息:{}", msg);
    }

}
